package demo.aspect.redis;

import demo.utils.JoinPointUtil;
import demo.utils.JedisProfilingUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Before;


import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class Jedis2ProfilingAspect {

    @Pointcut("execution(redis.clients.jedis.Connection redis.clients.jedis.Connection.sendCommand(redis.clients.jedis.Protocol.Command, byte[]...))")
    public void jedis2sendCommand() {
    }

    @Before("jedis2sendCommand()")
    public void beforeJedis2sendCommand(JoinPoint joinPoint) {
        JoinPointUtil.printJoinPoint(joinPoint);
        JedisProfilingUtil.beforeSendCmd(joinPoint);
    }

    @Pointcut("execution(Object redis.clients.jedis.Connection.readProtocolWithCheckingBroken())")
    public void jedis2readProtocolWithCheckingBroken() {
    }

    @After("jedis2readProtocolWithCheckingBroken()")
    public void afterJedis2readProtocolWithCheckingBroken(JoinPoint joinPoint) {
        JoinPointUtil.printJoinPoint(joinPoint);
    }
}
